/*Joseph A. Coll
11/14/2024
Combining 2012, 2016 and 2020 SPAE*/

*Combining surveys
*2012
use "G:\My Drive\Backup 08202022\Working Papers\Michaels Edited Volume\Election Policies Fraud Beliefs Confidence\Data and Methods\2012 SPAE Cleaned.dta", clear

*2016
append using "G:\My Drive\Backup 08202022\Working Papers\Michaels Edited Volume\Election Policies Fraud Beliefs Confidence\Data and Methods\2016 SPAE Cleaned.dta", force

*2020
append using "G:\My Drive\Backup 08202022\Working Papers\Michaels Edited Volume\Election Policies Fraud Beliefs Confidence\Data and Methods\2020 SPAE Cleaned.dta", force

*Merging COVI
merge m:m state_abbrev year using "G:\My Drive\Backup 08202022\Data Sets\COVI\Updated COVI 1996-2022 With Midterms, Lags, Leads, Change.dta", gen(_mergeCOVI)
tab state_abbrev if _mergeCOVI ==1
drop if _mergeCOVI != 3
label var covi_updated "COVI"

*Merge VID
merge m:m state_abbrev year using "G:\My Drive\Backup 08202022\Data Sets\Electoral Laws\Voter ID\Voter ID NCSL 2000-2020 Cleaned.dta", gen(_mergeVID)
tab state_abbrev if _mergeVID ==2
drop if _mergeCOVI != 3
label var covi_updated "COVI"
 

*Summary Statistics
reg voter_fraud_scale /// DV
c.covi_updated ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
ind_nolean rep_w_lean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic /// Race/Ethnicity
i.year ///
[pw=weight], robust cluster(state_fips)

sum voter_fraud_scale /// DV
covi_updated ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
ind_nolean rep_w_lean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic [aw=weight] if e(sample)==1

*Fraud scale diagnostics
alpha fraud_voter fraud_impersonation fraud_noncitizen fraud_wrongabsentee, item
********************************************************************************
********************************************************************************
*All Voters
********************************************************************************
********************************************************************************
*All years
reg voter_fraud_scale /// DV
c.covi_updated ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
ind_nolean rep_w_lean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic /// Race/Ethnicity
i.year ///
[pw=weight], robust cluster(state_fips)
estimates store	allR_allY
estadd loc Controls = "Yes"

	margins, at(covi_updated=(-1.4(.1)1.4) voted_first_time=0 voted_early=0 voted_mail=0 wait_time4=2 reg_problem=0 machine_problem=0 difficulty_finding_poll=1 asked_photo=0  /// Voting Exp.
	ind_nolean=0 rep_w_lean=0 liberalism=3 poli_int=1   /// Poli Characteristics
	age=49 income_mean=7 educ=2 married=1 female=1 /// SES
	hispanic=0 black_non_hispanic=0 other_non_hispanic=0) 

	marginsplot, name(allR_allY, replace) ///
	recastci(rarea) ///
	plot1opts(lcolor(black) color(black) msymbol(|)) ///
	ci1opts(color(black)) ///
	xtitle("Cost of Voting Index") ///
	xlabel(-1.4 `" "Low" "Costs" "' 0 "Balanced" 1.4 `" "High" "Costs" "') ///
	ylabel(0 "0 (Low)" ///
	25 "25" ///
	50 "50" ///
	75 "75" ///
	100 "100 (High)", angle(0)) ///
	ytitle("Fraud Belief Scale") ///
	title("All Years") ///
	graphregion(color(white)) 
	
*2012
reg voter_fraud_scale /// DV
c.covi_updated ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
ind_nolean rep_w_lean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic /// Race/Ethnicity
[pw=weight] if year ==2012, robust cluster(state_fips)
estimates store	allR_2012
estadd loc Controls = "Yes"

*2016
reg voter_fraud_scale /// DV
c.covi_updated ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
ind_nolean rep_w_lean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic /// Race/Ethnicity
[pw=weight] if year ==2016, robust cluster(state_fips)
estimates store	allR_2016
estadd loc Controls = "Yes"

*2020
reg voter_fraud_scale /// DV
c.covi_updated ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
ind_nolean rep_w_lean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic /// Race/Ethnicity
[pw=weight] if year ==2020, robust cluster(state_fips)
estimates store	allR_2020
estadd loc Controls = "Yes"

	margins, at(covi_updated=(-1.4(.1)1.4) voted_first_time=0 voted_early=0 voted_mail=0 wait_time4=2 reg_problem=0 machine_problem=0 difficulty_finding_poll=1 asked_photo=0  /// Voting Exp.
	ind_nolean=0 rep_w_lean=0 liberalism=3 poli_int=1   /// Poli Characteristics
	age=49 income_mean=7 educ=2 married=1 female=1 /// SES
	hispanic=0 black_non_hispanic=0 other_non_hispanic=0) 

	marginsplot, name(allR_2020, replace) ///
	recastci(rarea) ///
	plot1opts(lcolor(black) color(black) msymbol(|)) ///
	ci1opts(color(black)) ///
	xtitle("Cost of Voting Index") ///
	xlabel(-1.4 `" "Low" "Costs" "' 0 "Balanced" 1.4 `" "High" "Costs" "') ///
	ylabel(0 "0 (Low)" ///
	25 "25" ///
	50 "50" ///
	75 "75" ///
	100 "100 (High)", angle(0)) ///
	ytitle("Fraud Belief Scale") ///
	title("2020") ///
	graphregion(color(white))  

graph combine allR_allY allR_2020

esttab allR_allY allR_2012 allR_2016 allR_2020 ///
using Coll_Elect_Policy_Fraud_FullSample.rtf, replace ///
cells(b(star fmt(3)) se(fmt(3) par)) starlevels( * 0.05 ** 0.01 *** 0.001) ///
label note("Linear regression predicting fraud beliefs (0[low]-100[high])." ///
"All models estimated with robust standard errors clustered by state. Model 1 includes year fixed effects. *0.05 **0.01 ***0.001") ///
ar2 obslast scalars(Controls) ///
nodepvars nobase noomitted eqlabel("") interaction(" x ") ///
keep(covi_updated) ///
 title("Table XX: The Effects of the Cost of Voting Index on Voter Fraud Beliefs Among American Voters") ///
mlabel("All Years" "2012" "2016" "2020") 

esttab allR_allY allR_2012 allR_2016 allR_2020 ///
using Coll_Elect_Policy_Fraud_FullSample_fulltable.rtf, replace ///
cells(b(star fmt(3)) se(fmt(3) par)) starlevels( * 0.05 ** 0.01 *** 0.001) ///
label note("Linear regression predicting fraud beliefs (0[low]-100[high])." ///
"All models estimated with robust standard errors clustered by state. Model 1 includes year fixed effects. *0.05 **0.01 ***0.001") ///
ar2 obslast scalars(Controls) ///
nodepvars nobase noomitted eqlabel("") interaction(" x ") ///
order(covi_updated ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
ind_nolean rep_w_lean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic ) ///
drop(*.year) ///
 title("Table XX: The Effects of the Cost of Voting Index on Voter Fraud Beliefs Among American Voters") ///
mlabel("All Years" "2012" "2016" "2020") 

********************************************************************************
********************************************************************************
*Partisan Interactions
********************************************************************************
********************************************************************************
*All years
reg voter_fraud_scale /// DV
c.covi_updated##rep_w_lean ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
ind_nolean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic /// Race/Ethnicity
i.year ///
[pw=weight], robust cluster(state_fips)
estimates store	int_allY
estadd loc Controls = "Yes"

*2012
reg voter_fraud_scale /// DV
c.covi_updated##rep_w_lean ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
ind_nolean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic /// Race/Ethnicity
[pw=weight] if year ==2012, robust cluster(state_fips)
estimates store	int_2012
estadd loc Controls = "Yes"

*2016
reg voter_fraud_scale /// DV
c.covi_updated##rep_w_lean ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
ind_nolean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic /// Race/Ethnicity
[pw=weight] if year ==2016, robust cluster(state_fips)
estimates store	int_2016
estadd loc Controls = "Yes"

*2020
reg voter_fraud_scale /// DV
c.covi_updated##rep_w_lean ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
 ind_nolean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic /// Race/Ethnicity
[pw=weight] if year ==2020, robust cluster(state_fips)
estimates store	int_2020
estadd loc Controls = "Yes"

	margins rep_w_lean, at(covi_updated=(-1.4(.1)1.4) voted_first_time=0 voted_early=0 voted_mail=0 wait_time4=2 reg_problem=0 machine_problem=0 difficulty_finding_poll=1 asked_photo=0  /// Voting Exp.
	ind_nolean=0 liberalism=3 poli_int=1   /// Poli Characteristics
	age=49 income_mean=7 educ=2 married=1 female=1 /// SES
	hispanic=0 black_non_hispanic=0 other_non_hispanic=0) 

	marginsplot, name(int_2020, replace) ///
	recastci(rarea) ///
	plot1opts(lcolor(navy) color(navy) msymbol(|)) ///
	ci1opts(color(navy)) ///
	plot2opts(lcolor(maroon) color(maroon) msymbol(|)) ///
	ci2opts(color(maroon)) ///
	xtitle("Cost of Voting Index") ///
	xlabel(-1.4 `" "Low" "Costs" "' 0 "Balanced" 1.4 `" "High" "Costs" "') ///
	ylabel(0 "0 (Low)" ///
	25 "25" ///
	50 "50" ///
	75 "75" ///
	100 "100 (High)", angle(0)) ///
	ytitle("Fraud Belief Scale") ///
	title("2020") ///
	graphregion(color(white)) ///
	legend(pos(6) order(1 "Democrats" 2 "Republicans") region(lstyle(solid)) col(2))	 

esttab int_allY int_2012 int_2016 int_2020 ///
using Coll_Elect_Policy_Fraud_InteractionSample.rtf, replace ///
cells(b(star fmt(3)) se(fmt(3) par)) starlevels( * 0.05 ** 0.01 *** 0.001) ///
label note("Linear regression predicting fraud beliefs (0[low]-100[high])." ///
"All models estimated with robust standard errors clustered by state. Model 1 includes year fixed effects. *0.05 **0.01 ***0.001.") ///
ar2 obslast scalars(Controls) ///
nodepvars nobase noomitted eqlabel("") interaction(" x ") ///
keep(covi_updated *.covi_updated *.rep_w_lean) ///
 title("Table XX: The Differential Effects of the Cost of Voting Index on Voter Fraud Beliefs Between Republican and Democratic Voters") ///
mlabel("All Years" "2012" "2016" "2020") 

esttab int_allY int_2012 int_2016 int_2020 ///
using Coll_Elect_Policy_Fraud_InteractionSample_fulltable.rtf, replace ///
cells(b(star fmt(3)) se(fmt(3) par)) starlevels( * 0.05 ** 0.01 *** 0.001) ///
label note("Linear regression predicting fraud beliefs (0[low]-100[high])." ///
"All models estimated with robust standard errors clustered by state. Model 1 includes year fixed effects. *0.05 **0.01 ***0.001.") ///
ar2 obslast scalars(Controls) ///
nodepvars nobase noomitted eqlabel("") interaction(" x ") ///
order(covi_updated  *.rep_w_lean *.covi_updated  ///COVI
/// Fraud
voted_first_time voted_early voted_mail wait_time4 reg_problem machine_problem difficulty_finding_poll asked_photo  /// Voting Exp.
ind_nolean liberalism poli_int   /// Poli Characteristics
age income_mean educ married female /// SES
hispanic black_non_hispanic other_non_hispanic ) ///
drop(*.year) ///
 title("Table XX: The Differential Effects of the Cost of Voting Index on Voter Fraud Beliefs Between Republican and Democratic Voters") ///
mlabel("All Years" "2012" "2016" "2020") 

